//
//  NSDictionary+CycleDict.m
//  CycleControlFunction
//
//  Created by ddy on 2018/8/7.
//  Copyright © 2018年 ddy. All rights reserved.
//

#import "NSDictionary+CycleDict.h"

@implementation NSDictionary (CycleDict)
/**
 *  1.传入json文件或者plist文件返回字典，如（red.json）
 */
+ (NSDictionary *)cycle_getDictFromJsonFileName:(NSString *)fileName type:(NSString *)type{
    
    NSString *path = [[NSBundle mainBundle]pathForResource:fileName ofType:type];
    NSError *error = nil;
    NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:path] options:NSJSONReadingMutableContainers | NSJSONReadingAllowFragments error:&error];
    
    if(error != nil){
        return nil;
    } else {
        return dict;
    }
}
@end
